/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#include "CheckBox.h"
#include "view/CheckBox.h"
#include <xml/Stream.h>

namespace liba
{
namespace lib2d
{
namespace gui
{

CheckBox::CheckBox( Object * parent, const Rect & rect )
:	Button( parent, rect ),
	checked( false )
{
	view::CheckBox * view = new view::CheckBox( this );
	AutoPtr< resource::Resource > res = resource::Manager::create_resource( "check_box.xml" );
	xml::StreamResource( res ).load( &xml::Root( view, "CheckBoxData" ) );
	this->view = view;

	window_rect.width = view->get_width();
	window_rect.height = view->get_height();
}

CheckBox::~CheckBox()
{}

void CheckBox::on_button_up( const Vector2 & point, const Atom & button_name )
{
	if( is_pressed() )
		checked = !checked;
	//TODO action

	Button::on_button_up( point, button_name );
}

bool CheckBox::on_attribute( xml::Provider * prov, const std::string & name, const std::string & value )
{
	return false;
}

} //namespace gui
} //namespace lib2d
} //namespace liba

